﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Television
{
    class TV
    {
        private int currentChannel;
        private List<Channel> channels = new List<Channel>();

        public int CurrentChannel
        {
            get
            {
                return currentChannel;
            }
            set
            {
                currentChannel = value;
            }
        }

        public List<Channel> Channels
        {
            get
            {
                return channels;
            }
            private set
            {
                channels = value;
            }
        }

        public void SwitchChannelUp()
        {
            CurrentChannel += 1;
            if (CurrentChannel > channels[channels.Count-1].ChannelNumber)
            {
                CurrentChannel = channels[0].ChannelNumber;
            }
        }

        public void SwitchChannelDown()
        {
            CurrentChannel -= 1;
            if (CurrentChannel < channels[0].ChannelNumber)
            {
                CurrentChannel = channels[channels.Count-1].ChannelNumber;
            }
        }

        public void ShowCurrentChannel()
        {
            foreach (var canal in channels)
            {
                if (CurrentChannel==canal.ChannelNumber)
                {
                    Console.Write("Current channel is: ");
                    canal.ShowCanalInfo();
                }
            }
            
        }
    }
}
